package com.example.mywechatprogram.mapper;

import com.example.mywechatprogram.entity.Book;
import com.example.mywechatprogram.entity.UsersBook;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface BookMapper {
    @Insert("insert into users_book (users_UUID, users_book) values (#{UUID}, #{bookId})")
    public int addBook(@Param("UUID") String userId, @Param("bookId") String bookId);
    @Delete("delete from users_book where users_UUID=#{UUID} and users_book=#{bookId}")
    public int delBook(@Param("UUID") String userId, @Param("bookId") String bookId);
    @Select("select * from books")
    public List<Book> find();

    @Select("SELECT users_book.users_book FROM users_book WHERE users_book.users_UUID=#{UUID}")
    List<UsersBook> query(@Param("UUID")String UUID);
}
